package com.tsky.yyj.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tsky.casing.QueryBean;
import com.tsky.casing.action.BackAction;
import com.tsky.common.ActionUtil;
import com.tsky.common.BeanUtil;
import com.tsky.yyj.entity.Recharge;
import com.tsky.yyj.json.YYJJsonFormat;
import com.tsky.yyj.manager.BaseManager;

@Component("rechargeAction")
@Scope("prototype")
public class RechargeAction extends BackAction {
	@Autowired
	private BaseManager entityManager;

	/* bean properties */
	private String id;
	private String ids;
	private int money;// 充值金额
	private String name;// 账户

	public void grid() {
		QueryBean grid = new QueryBean();
		BeanUtil.copyProperties(grid, this);

		entityManager.query(grid, Recharge.class);

		String jsonData = YYJJsonFormat.rechargeToJson(grid);
		ActionUtil.ajaxWrite(jsonData);
	}

	public void add() {
		Recharge entity = new Recharge();
		BeanUtil.copyProperties(entity, this);
		entity.setId(BeanUtil.getID());
		entity.setExecDate(BeanUtil.getTimeStamp());

		boolean result = entityManager.saveEntity(entity);
		ActionUtil.ajaxWrite(result);
	}

	public String query() {
		Recharge entity = entityManager.getEntity(Recharge.class, id);
		ActionUtil.setToEL("areaEnt", entity);
		return "query";
	}

	public BaseManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(BaseManager entityManager) {
		this.entityManager = entityManager;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
